<style>
  .import {
    opacity: 0;
    position: absolute;
    width: 69px;
    height: 38px;
    margin-left: -10px;
  }

  .detailHide {
    border: none;
  }

  .deviceForm label,
  .batchAddDeviceForm label {
    width: 100px;
  }

  .deviceForm .layui-inline,
  .deviceForm .layui-form-item .layui-inline,
  .batchAddDeviceForm .layui-inline,
  .batchAddDeviceForm .layui-form-item .layui-inline {
    margin-bottom: 15px;
  }

  .companyFormPhotos {
    /* margin-left:140px; */
    line-height: 38px;
    float: left;
    margin-right: 5px;
  }

  .companyFormPhotos img {
    cursor: pointer;
    height: 38px;
    width: auto;
    max-width: 100px;
  }

  .deviceForm .layui-form-item .layui-input-inline,
  .batchAddDeviceForm .layui-form-item .layui-input-inline {
    width: 220px;
  }
</style>
<!-- 正文开始 -->
<div class="layui-fluid">
  <div class="layui-card">
    <div class="layui-card-body">
      <!-- 头部操作栏 -->
      <div class="layui-form lay-header">
        <div class="toolbar">
          <div class="layui-form-item lay-query-content">
            <div class="lay-query-box">
              <div class="query-lt">
                <div class="layui-inline">
                  <label class="layui-form-label w-auto">按分类：</label>
                  <div class="layui-input-inline">
                    <input name="categoryId" type="hidden" />
                    <div
                      class="layui-input-inline"
                      id="selectCategoryForm"
                    ></div>
                  </div>
                </div>
                <div class="layui-inline">
                  <label class="layui-form-label w-auto">设备类型：</label>
                  <div class="layui-input-inline">
                    <select
                      id="toolDeviceType"
                      name="deviceType"
                      lay-filter="deviceType"
                      class="common-select-search"
                    >
                      <option value="">请选择类型</option>
                    </select>
                  </div>
                </div>
                <div class="layui-inline">
                  <label class="layui-form-label w-auto">设备型号：</label>
                  <div class="layui-input-inline">
                    <input
                      name="deviceModel"
                      id="deviceModel"
                      class="layui-input"
                      type="text"
                      placeholder="请输入设备型号"
                      autocomplete="off"
                    />
                  </div>
                </div>
                <div class="layui-inline">
                  <label class="layui-form-label w-auto">设备名称：</label>
                  <div class="layui-input-inline">
                    <input
                      name="name"
                      id="pName"
                      class="layui-input"
                      type="text"
                      placeholder="请输入设备名称"
                      autocomplete="off"
                    />
                  </div>
                </div>
                <div class="layui-inline">
                  <label class="layui-form-label w-auto">设备编码：</label>
                  <div class="layui-input-inline">
                    <input
                      name="deviceCode"
                      id="pDeviceCode"
                      class="layui-input"
                      type="text"
                      placeholder="请输入设备编码"
                      autocomplete="off"
                    />
                  </div>
                </div>
                <div class="layui-inline">
                  <label class="layui-form-label">创建时间：</label>
                  <div class="layui-input-inline">
                    <input
                      name="createTime"
                      id="pTime"
                      class="layui-input"
                      type="text"
                      placeholder="选择时间"
                      autocomplete="off"
                      readonly
                    />
                  </div>
                  <input name="startTime" id="startTime" type="hidden" />
                  <input name="endTime" id="endTime" type="hidden" />
                </div>
              </div>
              <div class="query-rt">
                <div class="layui-inline">
                  <button
                    class="layui-btn icon-btn color-green"
                    lay-filter="formSubSearchLog"
                    lay-submit
                    layui-form-keyDownSearch="true"
                  >
                    查询
                  </button>
                  <button
                    class="layui-btn icon-btn color-white"
                    lay-filter="resets"
                    lay-submit
                  >
                    重置
                  </button>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="lay-btn-rows">
          <div class="lay-btn-box">
            <div class="lay-btn-lt">
              <button id="deviceBtnAdd" class="layui-btn icon-btn color-reseda">
                添加
              </button>
              <button class="layui-btn icon-btn color-reseda">
                <input
                  id="uploaderInput"
                  type="file"
                  name="file"
                  class="import"
                  accept=".xls,.xlsx"
                />导入
              </button>
              <button
                id="configFun"
                style="display: none"
                class="layui-btn icon-btn color-reseda"
                type="button"
              >
                确认选择
              </button>
            </div>
            <div class="lay-btn-rt">
              <button
                id="deviceBtnTemplate"
                class="layui-btn icon-btn color-green"
              >
                模板下载
              </button>
              <button
                id="deviceBtnExport"
                class="layui-btn icon-btn color-green"
              >
                导出
              </button>
              <!--                            <button class="layui-btn layui-btn-danger" lay-event="batchDel" type="button" id="batchDel">-->
              <!--                                批量删除-->
              <!--                            </button>-->
            </div>
          </div>
        </div>
      </div>
      <!-- 表格 -->
      <table
        class="layui-table"
        id="deviceTable"
        lay-filter="deviceTable"
      ></table>
    </div>
  </div>
</div>

<!-- 表格操作列 -->
<script type="text/html" id="deviceTableBar">
  <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="info">详情</a>
  <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="edit">修改</a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
  <a class="layui-btn layui-btn-xs" lay-event="printBarcode">打印条码</a>
</script>

<!--表格头工具-->
<script type="text/html" id="toolbar">
  <div class="layui-btn-container">
    <button class="layui-btn layui-btn-danger" lay-event="batchDel">
      批量删除
    </button>
  </div>
</script>

<!-- 表单弹窗 -->
<script type="text/html" id="deviceForm">
  <form
    lay-filter="deviceForm"
    class="layui-form model-form deviceForm"
    style="padding: 20px 10px 0;height: calc(100% - 20px);overflow: hidden;"
  >
    <div
      class="open-details-box"
      style="height: calc(100% - 65px); overflow-y: scroll;"
    >
      <input name="id" type="hidden" />
      <div class="layui-form-item layui-row">
        <div class="layui-col-md4">
          <label class="layui-form-label">设备类型</label>
          <div class="layui-input-inline">
            <select
              name="deviceType"
              lay-filter="deviceType"
              id="deviceType"
            ></select>
          </div>
        </div>
        <div class="layui-col-md4">
          <label class="layui-form-label">设备型号</label>
          <div class="layui-input-inline">
            <select
              name="deviceModelId"
              lay-filter="deviceModelId"
              id="deviceModelId"
            ></select>
          </div>
        </div>
        <div class="layui-col-md4">
          <label class="layui-form-label">设备编码</label>
          <div class="layui-input-inline">
            <input
              name="deviceCode"
              placeholder="请输入设备编码"
              type="text"
              class="layui-input"
              lay-verify="required"
              autocomplete="off"
            />
          </div>
        </div>
      </div>
      <div class="layui-form-item layui-row">
        <div class="layui-col-md4">
          <label class="layui-form-label">设备名称</label>
          <div class="layui-input-inline">
            <input
              name="name"
              placeholder="请输入设备名称"
              type="text"
              class="layui-input"
              lay-verify="required"
              autocomplete="off"
            />
          </div>
        </div>
        <div class="layui-col-md4">
          <label class="layui-form-label">设备分类</label>
          <input name="categoryId" type="hidden" />
          <div
            class="layui-input-inline"
            id="selectCategory"
            style="width:220px "
          ></div>
        </div>
        <div class="layui-col-md4">
          <label class="layui-form-label">设备品牌</label>
          <div class="layui-input-inline">
            <input
              type="hidden"
              name="deviceBrandId"
              readonly
              class="layui-input"
            />
            <input
              type="text"
              name="deviceBrandName"
              readonly
              class="layui-input"
            />
          </div>
        </div>
      </div>
      <div class="layui-form-item layui-row">
        <div class="layui-col-md4">
          <label class="layui-form-label">所属车间</label>
          <div class="layui-input-inline">
            <select name="workshopId"></select>
          </div>
          <div class="layui-form-mid layui-word-aux">
            <a
              href="#/device/deviceWorkshop"
              class="layui-btn layui-btn-xs"
              ew-event="closeDialog"
            >
              <i class="layui-icon layui-icon-addition"></i>
            </a>
          </div>
        </div>
        <div class="layui-col-md4">
          <label class="layui-form-label">设备厂家</label>
          <div class="layui-input-inline">
            <input
              type="text"
              name="factoryName"
              readonly
              class="layui-input"
              id="factoryName"
            />
          </div>
        </div>
        <div class="layui-col-md4">
          <label class="layui-form-label">设备供应商</label>
          <div class="layui-input-inline">
            <select
              name="supplierId"
              id="supplierId"
              lay-filter="supplierId"
            ></select>
          </div>
        </div>
      </div>
      <div class="layui-form-item layui-row">
        <div class="layui-col-md4">
          <label class="layui-form-label">供应商联系人</label>
          <div class="layui-input-inline">
            <select
              name="supplierContactId"
              id="supplierContactId"
              lay-filter="supplierContactId"
            ></select>
          </div>
        </div>
        <div class="layui-col-md4">
          <label class="layui-form-label">供应商电话</label>
          <div class="layui-input-inline">
            <input
              type="text"
              name="supplierPhone"
              class="layui-input"
              id="supplierPhone"
            />
          </div>
        </div>
        <div class="layui-col-md4">
          <label class="layui-form-label">供应商网址</label>
          <div class="layui-input-inline">
            <input
              type="text"
              name="supplierUrl"
              class="layui-input"
              id="supplierUrl"
            />
          </div>
        </div>
      </div>
      <div class="layui-form-item layui-row">
        <div class="layui-col-md4">
          <label class="layui-form-label">供应商地址</label>
          <div class="layui-input-inline">
            <input
              type="text"
              name="supplierAddress"
              class="layui-input"
              id="supplierAddress"
            />
          </div>
        </div>
        <div class="layui-col-md4">
          <label class="layui-form-label">采购金额</label>
          <div class="layui-input-inline">
            <input
              type="text"
              name="devicePrice"
              class="layui-input"
              id="devicePrice"
            />
          </div>
        </div>
        <div class="layui-col-md4">
          <label class="layui-form-label">人脸激活码</label>
          <div class="layui-input-inline">
            <input
              type="text"
              name="faceCode"
              class="layui-input"
              id="faceCode"
            />
          </div>
        </div>
      </div>
      <div class="layui-form-item layui-row">
        <div class="layui-col-md4">
          <label class="layui-form-label">所属企业</label>
          <div class="layui-input-inline">
            <select
              name="companyInfoId"
              lay-filter="companyInfoId"
              lay-verify="required"
            ></select>
          </div>
        </div>
        <div class="layui-col-md4">
          <label class="layui-form-label">所属部门</label>
          <input name="departmentId" type="hidden" />
          <div
            class="layui-input-inline"
            id="departmentId"
            style="width:220px"
          ></div>
        </div>
        <div class="layui-col-md4">
          <label class="layui-form-label">资产编码</label>
          <div class="layui-input-inline">
            <input
              name="propertyCode"
              placeholder="请输入资产编码"
              type="text"
              class="layui-input"
              lay-verify="required"
              autocomplete="off"
            />
          </div>
        </div>
      </div>
      <div class="layui-form-item layui-row">
        <div class="layui-col-md4">
          <label class="layui-form-label">待折旧金额</label>
          <div class="layui-input-inline">
            <input
              name="depreciationPrice"
              placeholder="请输入待折旧金额"
              type="text"
              class="layui-input"
              autocomplete="off"
            />
          </div>
        </div>
        <div class="layui-col-md4">
          <label class="layui-form-label">待折旧时长(月)</label>
          <div class="layui-input-inline">
            <input
              name="depreciationDuration"
              placeholder="请输入待折旧时长"
              type="text"
              class="layui-input"
              autocomplete="off"
            />
          </div>
        </div>
        <div class="layui-col-md4">
          <label class="layui-form-label">开始折旧时间</label>
          <div class="layui-input-inline">
            <input
              type="text"
              class="layui-input"
              id="depreciationTime"
              name="depreciationTime"
              readonly
            />
          </div>
        </div>
      </div>
      <div class="layui-form-item layui-row">
        <div class="layui-col-md4">
          <label class="layui-form-label">上次年检时间</label>
          <div class="layui-input-inline">
            <input
              type="text"
              class="layui-input"
              id="inspectTime"
              name="inspectTime"
              placeholder="上次年检时间"
              readonly
            />
          </div>
        </div>
        <div class="layui-col-md4">
          <label class="layui-form-label">下次年检时间</label>
          <div class="layui-input-inline">
            <input
              type="text"
              class="layui-input"
              id="inspectNextTime"
              name="inspectNextTime"
              placeholder="下次年检时间"
              readonly
            />
          </div>
        </div>
        <div class="layui-col-md4">
          <label class="layui-form-label">年检周期（天）</label>
          <div class="layui-input-inline">
            <input type="text" class="layui-input" name="inspectCycle" />
          </div>
        </div>
      </div>
      <div class="layui-form-item layui-row">
        <div class="layui-col-md4">
          <label class="layui-form-label">上次维护时间</label>
          <div class="layui-input-inline">
            <input
              type="text"
              class="layui-input"
              id="maintenanceTime"
              name="maintenanceTime"
              placeholder="上次维护时间"
              readonly
            />
          </div>
        </div>
        <div class="layui-col-md4">
          <label class="layui-form-label">下次维护时间</label>
          <div class="layui-input-inline">
            <input
              type="text"
              class="layui-input"
              id="maintenanceNextTime"
              name="maintenanceNextTime"
              placeholder="下次维护时间"
              readonly
            />
          </div>
        </div>
        <div class="layui-col-md4">
          <label class="layui-form-label">维保周期（天）</label>
          <div class="layui-input-inline">
            <input type="text" class="layui-input" name="maintenanceCycle" />
          </div>
        </div>
      </div>
      <div class="layui-form-item layui-row">
        <div class="layui-col-md4">
          <label class="layui-form-label">设备照片</label>
          <div class="layui-input-inline">
            <div id="devicePic_path" class="companyFormPhotos"></div>
            <div id="devicePicBtn" class="layui-btn" style="float: left;">
              <i class="layui-icon">&#xe681;</i>上传图片
            </div>
            <input
              name="devicePic"
              type="hidden"
              class="layui-input"
              lay-verify=""
              id="devicePic"
            />
          </div>
        </div>
        <div class="layui-col-md4">
          <label class="layui-form-label">设备资料</label>
          <div class="layui-input-block">
            <div
              id="btnUploadDviceAppendix_path"
              class="companyFormPhotos"
            ></div>
            <div
              id="btnUploadDviceAppendix"
              class="layui-btn"
              style="float: left;"
            >
              <i class="layui-icon">&#xe681;</i>上传
            </div>
            <input
              name="deviceAppendix"
              type="hidden"
              class="layui-input"
              lay-verify=""
              id="deviceAppendix"
            />
          </div>
        </div>

        <div class="layui-col-md4">
          <label class="layui-form-label">设备性质</label>
          <div class="layui-input-inline">
            <select
              name="deviceMent"
              lay-filter="deviceMent"
              id="deviceMent"
            ></select>
          </div>
        </div>
      </div>
      <div class="layui-form-item layui-row">
        <div class="layui-col-md4">
          <label class="layui-form-label">设备操作说明</label>
          <div class="layui-input-block">
            <div
              id="btnUploadDirectionUrl_path"
              class="companyFormPhotos"
            ></div>
            <div
              id="btnUploadDirectionUrl"
              class="layui-btn"
              style="float: left;"
            >
              <i class="layui-icon">&#xe681;</i>上传
            </div>
            <input
              name="directionUrl"
              type="hidden"
              class="layui-input"
              lay-verify=""
              id="directionUrl"
            />
          </div>
        </div>
        <div class="layui-col-md4">
          <label class="layui-form-label">其他附件资料</label>
          <div class="layui-input-block">
            <div id="btnUploadOtherUrl_path" class="companyFormPhotos"></div>
            <div id="btnUploadOtherUrl" class="layui-btn" style="float: left;">
              <i class="layui-icon">&#xe681;</i>上传
            </div>
            <input
              name="otherUrl"
              type="hidden"
              class="layui-input"
              lay-verify=""
              id="otherUrl"
            />
          </div>
        </div>

        <div class="layui-col-md4">
          <label class="layui-form-label">设备SOP资料</label>
          <div class="layui-input-block">
            <div
              id="btnUploadReferenceUrl_path"
              class="companyFormPhotos"
            ></div>
            <div
              id="btnUploadReferenceUrl"
              class="layui-btn"
              style="float: left;"
            >
              <i class="layui-icon">&#xe681;</i>上传
            </div>
            <input
              name="referenceUrl"
              type="hidden"
              class="layui-input"
              lay-verify=""
              id="referenceUrl"
            />
          </div>
        </div>
      </div>
      <div class="layui-form-item layui-row">
        <div class="layui-col-md4">
          <label class="layui-form-label">备注说明</label>
          <div class="layui-input-inline">
            <input
              name="remark"
              placeholder="请输入备注说明"
              type="text"
              class="layui-input"
              autocomplete="off"
            />
          </div>
        </div>
      </div>
    </div>
    <div class="layui-form-item text-right">
      <div class="layui-inline">
        <button
          class="layui-btn layui-btn-primary"
          type="button"
          ew-event="closeDialog"
        >
          取消
        </button>
      </div>
      <div class="layui-inline">
        <button class="layui-btn" lay-filter="deviceFormSubmit" lay-submit>
          保存
        </button>
      </div>
    </div>
  </form>
</script>

<!-- js部分 -->
<script>
  layui.use(
    ["layer", "form", "table", "admin", "upload", "laydate"],
    function () {
      var $ = layui.jquery;
      var layer = layui.layer;
      var form = layui.form;
      var table = layui.table;
      var config = layui.config;
      var admin = layui.admin;
      var upload = layui.upload;
      var laydate = layui.laydate;

      admin.selectSearch();
      let nowData = {};
      let where = {};
      if (typeof parentData !== "undefined") {
        nowData = { ...parentData };
        if (nowData.eventName == "radio" || nowData.eventName == "checkbox") {
          $("#configFun").show();
        }
        if (nowData.where) {
          where = nowData.where;
        }
        console.log(123,nowData);
      }

      var parentId;
      admin.reqSync(
        "enterprise/dict/admin/dictLabel/list?page=1&limit=10&dictType=sys_device_type_code",
        {},
        function (res) {
          if (res.code == 200) {
            parentId = res.data[0].labelValue;
          }
        }
      );

      //时间范围
      laydate.render({
        elem: "#pTime",
        type: "date",
        range: true,
        done: function (value, date, endDate) {
          if (value) {
            let dateValue = value.split(" - ");
            $("#startTime").val(dateValue[0] + " 00:00:00");
            $("#endTime").val(dateValue[1] + " 23:59:59");
          } else {
            $("#startTime").val("");
            $("#endTime").val("");
          }
          setTimeout(function () {
            $('[lay-filter="formSubSearchLog"]').click();
          }, 300);
        },
      });

      var treeData = [];
      admin.req(
        "enterprise/device/admin/deviceCategory/getTreeData",
        { limit: 9999 },
        function (res) {
          if (res.code == 200) {
            treeData = res.data;
          } else {
            //layer.msg('获取设备分类失败', {icon: 2, time: 1000});
          }
        },
        "GET",
        false
      );
      var selectedData = function (treeData, targetId) {
        for (var k = 0; k < treeData.length; k++) {
          var nodeId = treeData[k].value;
          if (targetId == nodeId) {
            treeData[k].selected = true;
            return;
          } else {
            if (treeData[k].children && treeData[k].children != "") {
              selectedData(treeData[k].children, targetId);
            }
          }
        }
      };

      let selectCategoryForm = xmSelect.render({
        el: "#selectCategoryForm",
        model: { label: { type: "text" } },
        radio: true,
        clickClose: true,
        filterable: true,
        tree: {
          show: true,
          strict: false,
          expandedKeys: [-1],
        },
        tips: "顶级分类",
        height: "auto",
        data() {
          return treeData;
        },
        on: function (data) {
          //被选中的select的id,如果没有 -1
          let parentId = data.arr.length > 0 ? data.change[0].value : "";
          $(".lay-header input[name='categoryId']").val(parentId);
          $('[lay-filter="formSubSearchLog"]').click();
        },
      });

      toolCabinetTypeData();

      function toolCabinetTypeData() {
        admin.req(
          "enterprise/product/admin/productType/list?page=1&limit=9999&parentId=" +
            parentId,
          {},
          function (res) {
            $.each(res.data, function (index, value) {
              // console.log(value.department_id);
              $("#toolDeviceType").append(new Option(value.name, value.id)); // 下拉菜单里添加元素
            });
            layui.form.render("select"); //重新渲染 固定写法
          },
          "GET"
        );
      }
      $("#configFun").click(function () {
        let list = table.checkStatus("deviceTable").data;
        childData.list = list;
        layer.close(nowData.zindex);
      });
      // 渲染表格
      var insTb = table.render({
        elem: "#deviceTable",
        url: config.base + "enterprise/device/admin/device/list",
        toolbar: true,
        defaultToolbar: ["filter"],
        page: true,
        cellMinWidth: 100,
        cols: [
          [
            {
              type: "checkbox",
              fixed: "left",
              hide: nowData.eventName == "radio" ?false  :true ,
            },
            { type: "numbers", title: "序号", fixed: "left" },
            { field: "name", sort: true, title: "设备名称", fixed: "left" },
            {
              field: "deviceCode",
              sort: true,
              title: "设备编码",
              fixed: "left",
            },
            { field: "deviceTypeName", sort: false, title: "设备类型" },
            { field: "deviceMentName", sort: false, title: "设备性质" },
            { field: "deviceModelName", sort: false, title: "设备型号" },
            { field: "categoryName", sort: false, title: "设备分类" },
            { field: "deviceBrandName", sort: false, title: "设备品牌" },
            { field: "propertyCode", sort: true, title: "资产编码" },
            { field: "workshopName", sort: false, title: "所属车间" },
            { field: "supplierName", sort: false, title: "供应商" },
            { field: "departmentName", sort: false, title: "所属部门" },
            { field: "enterpriseName", sort: false, title: "所属企业" },
            { field: "remark", sort: false, title: "备注描述" },
            { field: "statusDesc", sort: false, title: "状态" },
            { field: "creatorName", sort: false, title: "录入人" },
            { field: "createTime", sort: true, title: "添加时间" },
            {
              align: "center",
              toolbar: "#deviceTableBar",
              title: "操作",
              width: 300,
              fixed: "right",
            },

            // , {field: 'name', sort: true, title: '设备名称'}
            // , {field: 'categoryId', sort: true, title: '设备分类'}
            // , {field: 'departmentId', sort: true, title: '部门ID'}
          ],
        ],
        done: function (res, curr, count) {},
      });

      form.render("select");

      // 工具条点击事件
      table.on("tool(deviceTable)", function (obj) {
        var data = obj.data;
        if (obj.event === "edit") {
          //修改
          showEditModel(data, 2);
        } else if (obj.event === "del") {
          // 删除
          doDelete(obj);
        } else if (obj.event === "info") {
          //详情
          showEditModel(data, 1);
        } else if (obj.event === "printBarcode") {
          admin.getPrintBarcode(
            "enterprise/product/admin/productPackLabel/getBarCode",
            data.deviceCode
          );
        }
      });

      //监听排序
      table.on("sort(deviceTable)", function (obj) {
        table.reload("deviceTable", {
          initSort: obj,
          where: {
            sort: obj.field,
            order: obj.type,
          },
        });
      });

      // 搜索
      form.on("submit(formSubSearchLog)", function (data) {
        insTb.reload({ where: data.field, page: { curr: 1 } }, "data");
      });

      // 重置搜索
      form.on("submit(resets)", (data) => {
        $(".lay-header").find("select").val("");
        $(".lay-header").find("input").val("");
        let field = data.field;
        for (let key in field) {
          field[key] = "";
        }
        insTb.reload({ where: field, page: { curr: 1 } }, "data");
      });

      // 重置搜索
      form.on("submit(resets)", (data) => {
        $(".lay-header").find("select").val("");
        $(".lay-header").find("input").val("");
        let field = data.field;
        for (let key in field) {
          field[key] = "";
        }
        selectCategoryForm.setValue([]);
        // selectProductForm.setValue([]);
        insTb.reload({ where: field, page: { curr: 1 } }, "data");
      });

      // 添加按钮点击事件
      $("#deviceBtnAdd").click(function () {
        showEditModel();
      });

      // 批量添加
      $("#deviceBtnBatchAdd").click(function () {
        batchAddDevice();
      });

      //批量删除
      table.on("toolbar(deviceTable)", function (obj) {
        var checkStatus = table.checkStatus(obj.config.id);
        switch (obj.event) {
          case "batchDel":
            var data = checkStatus.data;
            batchDel(data);
            break;
        }
      });
      $("#batchDel").click(() => {
        var checkStatus = table.checkStatus("deviceTable").data;
        batchDel(checkStatus);
      });

      /**
       * 批量删除
       * @param data
       */
      function batchDel(data) {
        //遍历取出数据量
        if (data == null || data.length <= 0 || data == undefined) {
          layer.msg("请先勾选数据", { icon: 2 });
          return;
        } else {
          let arrIds = [];
          data.forEach((i) => {
            arrIds.push(i.id);
          });
          layer.confirm(
            "确定要删除吗？",
            {
              offset: "65px",
              skin: "layui-layer-admin",
            },
            function (i) {
              layer.close(i);
              layer.load(2);
              if (arrIds.length > 0) {
                admin.req(
                  "enterprise/device/admin/device/batchIds",
                  { ids: arrIds },
                  function (res) {
                    layer.closeAll("loading");
                    if (res.code == 200) {
                      layer.msg(res.msg, { icon: 1 });
                      table.reload("deviceTable");
                    } else {
                      layer.msg(res.msg, { icon: 2 });
                    }
                  },
                  "DELETE"
                );
              }
            }
          );
        }
      }

      // 单个设备添加 （修改、详情）
      function showEditModel(data, type) {
        admin.open({
          type: 1,
          area: ["1260px", "700px"],
          offset: "65px",
          title: data
            ? type === 1
              ? "设备详情"
              : "设备修改"
            : "单个添加设备表",
          content: $("#deviceForm").html(),
          success: function () {
            laydate.render({
              elem: "#depreciationTime",
              type: "datetime",
            });
            laydate.render({
              elem: "#inspectTime",
              type: "datetime",
            });
            laydate.render({
              elem: "#inspectNextTime",
              type: "datetime",
            });
            laydate.render({
              elem: "#maintenanceTime",
              type: "datetime",
            });
            laydate.render({
              elem: "#maintenanceNextTime",
              type: "datetime",
            });

            let xmRenderData = [];
            form.render("select");

            admin.getDictList(
              "deviceMent",
              "device_ment_type",
              null,
              "设备性质"
            );

            // 设备型号
            admin.reqSync(
              "enterprise/device/admin/deviceModel/list?page=1&limit=9999",
              {},
              function (res) {
                if (res.code === 200) {
                  loadSelectHtml(
                    res.data,
                    "请选择设备型号",
                    "deviceModelId",
                    '[lay-filter="deviceForm"]',
                    1
                  );
                } else {
                  loadSelectHtml(
                    [],
                    "请选择设备型号",
                    "deviceModelId",
                    '[lay-filter="deviceForm"]',
                    1
                  );
                }
              },
              "get"
            );

            // 所属车间
            admin.reqSync(
              "enterprise/device/admin/deviceWorkshop/getAll?page=1&limit=9999",
              {},
              function (res) {
                if (res.code === 200) {
                  loadSelectHtml(
                    res.data,
                    "请选择所属车间",
                    "workshopId",
                    '[lay-filter="deviceForm"]',
                    2
                  );
                } else {
                  loadSelectHtml(
                    [],
                    "请选择所属车间",
                    "workshopId",
                    '[lay-filter="deviceForm"]',
                    2
                  );
                }
              },
              "get"
            );

            //查询设备类型
            admin.reqSync(
              "enterprise/product/admin/productType/list?page=1&limit=9999&parentId=" +
                parentId,
              {},
              function (res) {
                if (res.code === 200) {
                  loadSelectHtml(
                    res.data,
                    "请选择设备类型",
                    "deviceType",
                    '[lay-filter="deviceForm"]',
                    1
                  );
                } else {
                  loadSelectHtml(
                    [],
                    "请选择设备类型",
                    "deviceType",
                    '[lay-filter="deviceForm"]',
                    1
                  );
                }
              },
              "get"
            );

            // admin.initDataSelectTree(true, 'enterprise/device/admin/deviceType/getAllTypeOnlyPro', null, "selectProductType", data ? data.deviceType : null, "请选择设备类型", "deviceType", null);

            //查询设备供应商
            admin.reqSync(
              "enterprise/purchase/admin/supplierInfoPass/getAll",
              {},
              function (res) {
                if (res.code === 200) {
                  loadSelectHtml(
                    res.data,
                    "请选择设备供应商",
                    "supplierId",
                    '[lay-filter="deviceForm"]',
                    3
                  );
                } else {
                  loadSelectHtml(
                    [],
                    "请选择设备供应商",
                    "supplierId",
                    '[lay-filter="deviceForm"]',
                    3
                  );
                }
              },
              "get"
            );

            // 所属企业
            admin.reqSync(
              "user/admin/companyInfo/list?limit=9999",
              {},
              function (res) {
                if (res.code === 200) {
                  loadSelectHtml(
                    res.data,
                    "请选择企业",
                    "companyInfoId",
                    '[lay-filter="deviceForm"]',
                    2
                  );
                } else {
                  loadSelectHtml(
                    [],
                    "请选择企业",
                    "companyInfoId",
                    '[lay-filter="deviceForm"]',
                    2
                  );
                }
              },
              "get"
            );

            //所属企业下拉操作
            form.on("select(companyInfoId)", function (data) {
              if (data.value === "") {
                getDepartmentIdData();
              } else {
                getDepartmentIdData(data.value);
              }
            });
            //所属企业下拉操作
            form.on("select(supplierId)", function (data) {
              if (data.value === "") {
                getSupplierContact();
              } else {
                getSupplierContact(data.value);
              }
            });

            function getSupplierContact(data) {
              admin.reqSync(
                "enterprise/purchase/admin/supplierContacts/list",
                { corporateId: data.id },
                function (res) {
                  if (res.code === 200) {
                    loadSelectHtml(
                      res.data,
                      "请选择联系人",
                      "supplierContactId",
                      '[lay-filter="deviceForm"]',
                      4
                    );
                  } else {
                    loadSelectHtml(
                      [],
                      "请选择联系人",
                      "supplierContact",
                      '[lay-filter="deviceForm"]',
                      4
                    );
                  }
                },
                "get"
              );
            }

            let xmRender = xmSelect.render({
              el: "#departmentId",
              model: { label: { type: "text" } },
              radio: true,
              clickClose: true,
              filterable: true,
              tree: {
                show: true,
                strict: false,
                expandedKeys: [-1],
              },
              tips: "顶级分类",
              height: "auto",
              data() {
                return xmRenderData;
              },
              on: function (data) {
                //被选中的select的id,如果没有 -1
                let departmentId =
                  data.arr.length > 0 ? data.change[0].value : -1;
                $("[lay-filter='deviceForm'] input[name='departmentId']").val(
                  departmentId
                );
              },
            });

            function getDepartmentIdData(_data) {
              if (!_data) {
                xmRenderData = [];
                xmRender.update({ data: xmRenderData, autoRow: true });
                $("[lay-filter='deviceForm'] input[name='departmentId']").val(
                  ""
                );
                return false;
              } else {
                admin.reqSync(
                  "user/admin/role/getTreeData",
                  { limit: 9999 },
                  (res) => {
                    if (res.code === 200) {
                      xmRenderData = res.data;
                    } else {
                      xmRenderData = [];
                      $(
                        "[lay-filter='deviceForm'] input[name='departmentId']"
                      ).val("");
                    }
                    xmRender.update({ data: xmRenderData, autoRow: true });
                  },
                  "get"
                );
              }
            }

            //设备型号下拉操作
            form.on("select(deviceModelId)", function (data) {
              if (data.value === "") {
                deviceBrand();
              } else {
                let dataObj = JSON.parse(
                  $(data.elem[data.elem.selectedIndex]).attr("data")
                );
                deviceBrand(dataObj);
              }
            });

            //设备分类
            let selectCategorySelect = xmSelect.render({
              el: "#selectCategory",
              model: { label: { type: "text" } },
              radio: true,
              clickClose: true,
              filterable: true,
              tree: {
                show: true,
                strict: false,
                expandedKeys: [-1],
              },
              tips: "顶级分类",
              height: "auto",
              data() {
                return treeData;
              },
              on: function (data) {
                //被选中的select的id,如果没有 -1
                let parentId = data.arr.length > 0 ? data.change[0].value : -1;
                $(".deviceForm input[name='categoryId']").val(parentId);
              },
            });

            //设备品牌
            function deviceBrand(obj) {
              // 获取最大设备型号
              // if (obj.id != null && obj.id != "") {
              //   admin.reqSync(
              //     "enterprise/device/admin/device/getMaxModel",
              //     { devModelId: obj.id },
              //     (res) => {
              //       if (res.code === 200) {
              //         obj.deviceCode =
              //           obj.deviceHead + "-" + (Number(res.data) + 1);
              //         obj.name = obj.name + "-" + (Number(res.data) + 1);
              //       } else {
              //       }
              //     } 
              //   );
              // }
              if (obj) {
                $(
                  'form[lay-filter="deviceForm"] input[name="deviceBrandName"]'
                ).val(obj.deviceBrandName);
                $('form[lay-filter="deviceForm"] input[name="deviceCode"]').val(
                  obj.deviceCode
                );
                $(
                  'form[lay-filter="deviceForm"] input[name="propertyCode"]'
                ).val(obj.deviceCode);
                $('form[lay-filter="deviceForm"] input[name="name"]').val(
                  obj.name
                );

                $(
                  'form[lay-filter="deviceForm"] input[name="deviceBrandId"]'
                ).val(obj.deviceBrand);
                $(
                  'form[lay-filter="deviceForm"] input[name="factoryName"]'
                ).val(obj.factoryName);
                $("#btnUploadDviceAppendix_path").html(
                  "<img src='" + obj.deviceAppendix + "'/>"
                );
                $("#btnUploadReferenceUrl_path").html(
                  "<img src='" + obj.referenceUrl + "'/>"
                );
                $("#btnUploadDirectionUrl_path").html(
                  "<img src='" + obj.directionUrl + "'/>"
                );
                $("#btnUploadOtherUrl_path").html(
                  "<img src='" + obj.otherUrl + "'/>"
                );
              } else {
                $(
                  'form[lay-filter="deviceForm"] input[name="deviceBrandName"]'
                ).val("");
                $(
                  'form[lay-filter="deviceForm"] input[name="factoryName"]'
                ).val("");
              }
              // 查看大图
              layer.photos({
                photos: ".companyFormPhotos",
                anim: 5,
              });
            }

            if (data) {
              if (data.companyInfoId && data.companyInfoId != 0) {
                getDepartmentIdData(data.companyInfoId);
              }
              if (data.categoryId && data.categoryId != 0) {
                selectCategorySelect.setValue([data.categoryId]);
              }
              if (data.departmentId && data.departmentId != 0) {
                xmRender.setValue([data.departmentId]);
              }
              if (data.supplierId && data.supplierId != 0) {
                getSupplierContact(data.supplierId);
              }
              if (data.devicePic) {
                $("#devicePic_path").html(
                  '<img src="' + data.devicePic + '"/>'
                );
              }
              if (data.deviceAppendix) {
                $("#btnUploadDviceAppendix_path").html(
                  "<img src='" + data.deviceAppendix + "'/>"
                );
              }
              if (data.referenceUrl) {
                $("#btnUploadReferenceUrl_path").html(
                  "<img src='" + data.referenceUrl + "'/>"
                );
              }
              if (data.directionUrl) {
                $("#btnUploadDirectionUrl_path").html(
                  "<img src='" + data.directionUrl + "'/>"
                );
              }
              if (data.otherUrl) {
                $("#btnUploadOtherUrl_path").html(
                  "<img src='" + data.otherUrl + "'/>"
                );
              }

              if (type === 1) {
                selectCategorySelect.update({ disabled: true });
                xmRender.update({ disabled: true });
                $('form[lay-filter="deviceForm"] input').attr(
                  "readonly",
                  "readonly"
                );
                $('form[lay-filter="deviceForm"] select').attr(
                  "disabled",
                  "disabled"
                );
                $('button[lay-filter="deviceFormSubmit"]').remove();
                $("#devicePicBtn").remove();
                $("#btnUploadDviceAppendix").remove();
                $("#btnUploadReferenceUrl").remove();
                $("#btnUploadDirectionUrl").remove();
                $("#btnUploadOtherUrl").remove();

                form.render("select");
              } else {
                selectCategorySelect.update({ disabled: false });
                xmRender.update({ disabled: false });
                //设备照片
                $("#devicePicBtn").click(
                  uploadImg("devicePicBtn", "devicePic_path", "devicePic")
                );
                $("#btnUploadDviceAppendix").click(
                  uploadImg(
                    "btnUploadDviceAppendix",
                    "btnUploadDviceAppendix_path",
                    "deviceAppendix"
                  )
                );
                $("#btnUploadReferenceUrl").click(
                  uploadImg(
                    "btnUploadReferenceUrl",
                    "btnUploadReferenceUrl_path",
                    "referenceUrl"
                  )
                );
                $("#btnUploadDirectionUrl").click(
                  uploadImg(
                    "btnUploadDirectionUrl",
                    "btnUploadDirectionUrl_path",
                    "directionUrl"
                  )
                );
                $("#btnUploadOtherUrl").click(
                  uploadImg(
                    "btnUploadOtherUrl",
                    "btnUploadOtherUrl_path",
                    "otherUrl"
                  )
                );
              }
              // 查看大图
              layer.photos({
                photos: ".companyFormPhotos",
                anim: 5,
              });
            } else {
              selectCategorySelect.setValue([]);
              selectCategorySelect.update({ disabled: false });
              //设备照片
              $("#devicePicBtn").click(
                uploadImg("devicePicBtn", "devicePic_path", "devicePic")
              );
              $("#btnUploadDviceAppendix").click(
                uploadImg(
                  "btnUploadDviceAppendix",
                  "btnUploadDviceAppendix_path",
                  "deviceAppendix"
                )
              );
              $("#btnUploadReferenceUrl").click(
                uploadImg(
                  "btnUploadReferenceUrl",
                  "btnUploadReferenceUrl_path",
                  "referenceUrl"
                )
              );
              $("#btnUploadDirectionUrl").click(
                uploadImg(
                  "btnUploadDirectionUrl",
                  "btnUploadDirectionUrl_path",
                  "directionUrl"
                )
              );
              $("#btnUploadOtherUrl").click(
                uploadImg(
                  "btnUploadOtherUrl",
                  "btnUploadOtherUrl_path",
                  "otherUrl"
                )
              );
            }

            // 表单提交事件
            form.on("submit(deviceFormSubmit)", function (d) {
              console.log(d.field);
              layer.load(2);
              admin.req(
                data
                  ? "enterprise/device/admin/device/update"
                  : "enterprise/device/admin/device/addDevice",
                d.field,
                function (res) {
                  layer.closeAll("loading");
                  if (res.code == 200) {
                    layer.msg(res.msg, { icon: 1 });
                    table.reload("deviceTable");
                    layer.closeAll("page");
                  } else {
                    layer.msg(res.msg, { icon: 2 });
                  }
                },
                data ? "PUT" : "POST"
              );
              return false;
            });
            form.val("deviceForm", data);
          },
        });
      }

      function batchAddDevice() {
        admin.open({
          type: 1,
          area: ["1280px", "600px"],
          offset: "65px",
          title: "批量添加设备",
          content: $("#batchAddDeviceForm").html(),
          success: function () {
            let xmRenderData = [];
            form.render("select");

            // 设备型号
            admin.reqSync(
              "enterprise/device/admin/deviceModel/list?page=1&limit=9999",
              {},
              function (res) {
                if (res.code === 200) {
                  loadSelectHtml(
                    res.data,
                    "请选择设备型号",
                    "deviceModelId",
                    '[lay-filter="batchAddDeviceForm"]',
                    1
                  );
                } else {
                  loadSelectHtml(
                    [],
                    "请选择设备型号",
                    "deviceModelId",
                    '[lay-filter="batchAddDeviceForm"]',
                    1
                  );
                }
              },
              "get"
            );

            // 所属车间
            admin.reqSync(
              "enterprise/device/admin/deviceWorkshop/getAll?page=1&limit=9999",
              {},
              function (res) {
                if (res.code === 200) {
                  loadSelectHtml(
                    res.data,
                    "请选择所属车间",
                    "workshopId",
                    '[lay-filter="batchAddDeviceForm"]',
                    2
                  );
                } else {
                  loadSelectHtml(
                    [],
                    "请选择所属车间",
                    "workshopId",
                    '[lay-filter="batchAddDeviceForm"]',
                    2
                  );
                }
              },
              "get"
            );

            //查询设备类型
            admin.reqSync(
              "enterprise/device/admin/deviceType/getAllTypeOnlyPro",
              {},
              function (res) {
                if (res.code === 200) {
                  loadSelectHtml(
                    res.data,
                    "请选择设备类型",
                    "deviceType",
                    '[lay-filter="batchAddDeviceForm"]',
                    1
                  );
                } else {
                  loadSelectHtml(
                    [],
                    "请选择设备类型",
                    "deviceType",
                    '[lay-filter="batchAddDeviceForm"]',
                    1
                  );
                }
              },
              "get"
            );

            //查询设备供应商
            admin.reqSync(
              "enterprise/purchase/admin/supplierInfoPass/getAll",
              {},
              function (res) {
                if (res.code === 200) {
                  loadSelectHtml(
                    res.data,
                    "请选择设备供应商",
                    "supplierId",
                    '[lay-filter="batchAddDeviceForm"]',
                    3
                  );
                } else {
                  loadSelectHtml(
                    [],
                    "请选择设备供应商",
                    "supplierId",
                    '[lay-filter="batchAddDeviceForm"]',
                    3
                  );
                }
              },
              "get"
            );

            $("#batchAddDevicePicBtn").click(
              uploadImg(
                "batchAddDevicePicBtn",
                "batchAddDevicePic_path",
                "devicePic"
              )
            );

            //设备型号下拉操作
            form.on("select(batchDeviceModelId)", function (data) {
              if (data.value === "") {
                deviceBrand();
              } else {
                let dataObj = JSON.parse(
                  $(data.elem[data.elem.selectedIndex]).attr("data")
                );
                deviceBrand(dataObj);
              }
            });

            //设备品牌 设备厂家
            function deviceBrand(obj) {
              if (obj) {
                $(
                  'form[lay-filter="batchAddDeviceForm"] input[name="deviceBrandName"]'
                ).val(obj.deviceBrandName);
                $(
                  'form[lay-filter="batchAddDeviceForm"] input[name="deviceBrandId"]'
                ).val(obj.deviceBrand);
                $(
                  'form[lay-filter="batchAddDeviceForm"] input[name="factoryName"]'
                ).val(obj.factoryName);
              } else {
                $(
                  'form[lay-filter="batchAddDeviceForm"] input[name="deviceBrandName"]'
                ).val("");
                $(
                  'form[lay-filter="batchAddDeviceForm"] input[name="factoryName"]'
                ).val("");
              }
            }

            //设备分类
            xmSelect.render({
              el: "#batchSelectCategory",
              model: { label: { type: "text" } },
              radio: true,
              clickClose: true,
              filterable: true,
              tree: {
                show: true,
                strict: false,
                expandedKeys: [-1],
              },
              tips: "顶级分类",
              height: "auto",
              data() {
                return treeData;
              },
              on: function (data) {
                //被选中的select的id,如果没有 -1
                let parentId = data.arr.length > 0 ? data.change[0].value : -1;
                $(".batchAddDeviceForm input[name='categoryId']").val(parentId);
              },
            });

            // 所属企业
            admin.reqSync(
              "user/admin/companyInfo/list?limit=9999",
              {},
              function (res) {
                if (res.code === 200) {
                  loadSelectHtml(
                    res.data,
                    "请选择企业",
                    "companyInfoId",
                    '[lay-filter="batchAddDeviceForm"]',
                    2
                  );
                } else {
                  loadSelectHtml(
                    [],
                    "请选择企业",
                    "companyInfoId",
                    '[lay-filter="batchAddDeviceForm"]',
                    2
                  );
                }
              },
              "get"
            );

            //所属企业下拉操作
            form.on("select(companyInfoId)", function (data) {
              if (data.value === "") {
                getDepartmentIdData();
              } else {
                getDepartmentIdData(data.value);
              }
            });

            let xmRender = xmSelect.render({
              el: "#departmentId1",
              model: { label: { type: "text" } },
              radio: true,
              clickClose: true,
              filterable: true,
              tree: {
                show: true,
                strict: false,
                expandedKeys: [-1],
              },
              tips: "顶级分类",
              height: "auto",
              data() {
                return xmRenderData;
              },
              on: function (data) {
                //被选中的select的id,如果没有 -1
                let departmentId =
                  data.arr.length > 0 ? data.change[0].value : -1;
                $(
                  "[lay-filter='batchAddDeviceForm'] input[name='departmentId']"
                ).val(departmentId);
              },
            });

            function getDepartmentIdData(_data) {
              if (!_data) {
                xmRenderData = [];
                xmRender.update({ data: xmRenderData, autoRow: true });
                $(
                  "[lay-filter='batchAddDeviceForm'] input[name='departmentId']"
                ).val("");
                return false;
              }
              admin.reqSync(
                "user/admin/department/getTreeData",
                { companyId: _data, limit: 9999 },
                (res) => {
                  if (res.code === 200) {
                    xmRenderData = res.data;
                  } else {
                    xmRenderData = [];
                    $(
                      "[lay-filter='batchAddDeviceForm'] input[name='departmentId']"
                    ).val("");
                  }
                  xmRender.update({ data: xmRenderData, autoRow: true });
                },
                "get"
              );
            }

            // 表单提交事件
            form.on("submit(batchAddDeviceFormSubmit)", function (d) {
              layer.load(2);
              admin.req(
                "enterprise/device/admin/device/add",
                d.field,
                function (res) {
                  layer.closeAll("loading");
                  if (res.code == 200) {
                    layer.msg(res.msg, { icon: 1 });
                    table.reload("deviceTable");
                    layer.closeAll("page");
                  } else {
                    layer.msg(res.msg, { icon: 2 });
                  }
                },
                "POST"
              );
              return false;
            });
          },
        });
      }

      /**
       * 加载地址HTML
       * @param data 下拉菜单数据
       * @param tips select 默认提示
       * @param htmltarget html要插入的位置
       * @param name  下拉框需要显示值的属性
       */
      function loadSelectHtml(data, tips, htmltarget, formName, type) {
        let html = " <option value>" + tips + "</option>";
        if (!data || data == null) {
          $("form" + formName + " select[name='" + htmltarget + "']").html(
            html
          );
          form.render("select");
          return;
        }
        for (let i = 0; i < data.length; i++) {
          if (type == 1) {
            html += `<option value='${data[i].id}' data='${JSON.stringify(
              data[i]
            )}'>${data[i].name}</option>`;
          } else if (type == 2) {
            html += `<option value='${data[i].id}'>${data[i].name}</option>`;
          } else if (type == 3) {
            html += `<option value='${data[i].id}'>${data[i].corporateName}</option>`;
          } else if (type == 4) {
            html += `<option value='${data[i].id}'>${data[i].contactName}</option>`;
          }
        }
        $("form" + formName + " select[name='" + htmltarget + "']").html(html);
        form.render("select");
      }

      // 删除
      function doDelete(obj) {
        layer.confirm(
          "确定要删除吗？",
          {
            offset: "65px",
            skin: "layui-layer-admin",
          },
          function (i) {
            layer.close(i);
            layer.load(2);
            admin.req(
              "enterprise/device/admin/device/" + obj.data.id,
              {},
              function (res) {
                layer.closeAll("loading");
                if (res.code == 200) {
                  layer.msg(res.msg, { icon: 1 });
                  obj.del();
                } else {
                  layer.msg(res.msg, { icon: 2 });
                }
              },
              "DELETE"
            );
          }
        );
      }

      // 上传文件
      function uploadImg(_elem, pathId, inputId) {
        upload.render({
          elem: "#" + _elem,
          url: config.upload_url + "uploadFile",
          data: {},
          accept: "file",
          exts: "jpg|png|RAR|zip|pdf|txt|doc|docx|xls|xlsx|ppt|pptx",
          headers: { Authorization: "Bearer " + config.getToken() },
          done: function (res) {
            if (res.code == 200) {
              layer.msg(res.msg || "上传成功", { icon: 1 });
              let imagUrl = res.data.url;
              $("#" + pathId).html('<img src="' + imagUrl + '"/>');
              $("#" + inputId).val(imagUrl);
            } else if (res.code == 502) {
              return location.replace("admin/login.html");
            } else {
              layer.msg(res.msg || "上传失败", { icon: 2 });
            }
          },
        });
      }

      // 模板下载
      $("#deviceBtnTemplate").click(function () {
        window.location.href =
          config.base + "enterprise/device/admin/device/deviceTemplate";
      });

      // 导入excel
      $("#uploaderInput").on("change", function (e) {
        layer.load(2);
        var formData = new FormData();
        var files = e.target.files;
        let that = $(this);
        formData.append("file", files[0]);
        formData.append("name", files[0].name); //这个地方可以传递多个参数
        $.ajax({
          url: config.base + "enterprise/device/admin/device/importExcel",
          data: formData,
          headers: { Authorization: "Bearer " + config.getToken() },
          type: "POST",
          processData: false,
          contentType: false,
          success: function (res) {
            layer.closeAll("loading");
            if (res.code == 200) {
              layer.msg(res.msg, { icon: 1 });
              layer.closeAll("page");
              setTimeout((_) => {
                location.reload();
              }, 1000);
            } else {
              layer.msg(res.msg, { icon: 2 });
            }
            that.val("");
          },
        });
      });

      // 导出1
      $("#deviceBtnExport").click(function () {
        var sTime = $("#startTime").val();
        var eTime = $("#endTime").val();

        location.href =
          config.base +
          "enterprise/device/admin/device/export?startCreateTime=" +
          sTime +
          "&endCreateTime=" +
          eTime +
          "&enterpriseCode=" +
          config.getUser().enterpriseCode;

        /*if (sTime == "" && eTime == "") {
                layer.msg('请先选择创建时间！')
            } else {
                location.href = config.base + 'enterprise/device/admin/device/export?startCreateTime=' + sTime + '&endCreateTime=' + eTime+ '&enterpriseCode=' + config.getUser().enterpriseCode;
            }*/
      });
    }
  );
</script>
